<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            background-color: #000;
            text-align: center;
            padding: 200px;
        }
        #content{
            margin: 0 auto;
            /* 内容隐藏 */
            display: none;
        }
        #num{
            font-size: 200px;
            color: red;
        }
        #content p{
            font-size: 20px;
            color: aqua;
        }
    </style>
</head>
<body>
    <div id="num">5</div>
    <div id="content">
        <img src="./img/flower.gif" alt="">
        <p>我喜欢你</p>
    </div>

    <script>
        window.addEventListener('load',function(){
            // let time = null;
            //开启定时器
            let time = setInterval(function(){
                $('num').innerText -= 1;
                //清除定时器
                if($('num').innerText  === '0'){
                    clearInterval(time);
                    //显示内容，隐藏数字
                    $('content').style.display = 'block';
                    $('num').style.display = 'none';
                }
            },1000);
        });
        function $(id){
            return typeof id === "string"?document.getElementById(id) : null;
        }
    </script>
</body>
</html>